<?php
class ProfileController extends Bib_Controller_Action {
    public function changePasswordAction()
	{
		$form = new Form_Auth_ChangePassword();

		if ($this->_request->isPost() && $form->isValid($this->_getAllParams())) {
			$user = clone $this->user;
			$user->haslo = sha1($form->getValue('password'));
			UserManager::getInstance()->save($user);

			$this->view->infoBox();
			$this->view->message = "Hasło zmienione.";
			$this->view->redirect = array('controller' => 'index');
		}

		$this->view->form = $form;
	}

    public function lendAction(){
        $user = Zend_Auth::getInstance()->getIdentity();

        $this->view->zamowione = $user->getLendsByType(Lend::TYPE_ORDERED);
        $this->view->wypozyczone = $user->getLendsByType(Lend::TYPE_LEND);
        $this->view->oczekujace = $user->getLendsByType(Lend::TYPE_WAITING);
        $this->view->zwrocone = $user->getLendsByType(Lend::TYPE_RETURNED);        
    }
}